Skip to content

feat(rag): Option A escalation rescue + monitoring evidence gate parity#1040

Merged
BigSimmo merged 12 commits into
mainfrom
claude/clinical-kb-pwa-review-asi3wb
Jul 21, 2026
Merged

feat(rag): Option A escalation rescue + monitoring evidence gate parity#1040
BigSimmo merged 12 commits into
mainfrom
claude/clinical-kb-pwa-review-asi3wb

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

The Option A wave (user-approved): kills the last blocking canary red and the answer-side half of the run-#60 monitoring targeting misses. Two single-concern changes plus a review-response hardening commit:

0abf3c9 — Option A: title-supported escalation rescue (protected retrieval surface). The neuroleptic-side-effect-escalation case failed the citation gate on every canary (#57→#60): the query misclassifies as medication_dose_risk, its honest lexical pool fails the dose fast-path floor (live-measured 0.184/0.0125 vs 0.66/0.055), the S3 document-lookup title layer was excluded by the class allowlist, and the vector leg injects the wrong sibling doc (Zuclopenthixol). shouldAttemptDocumentLookupFastPath now also engages the layer for medication_dose_risk when BOTH existing deterministic classifier signals hold: intent === "escalation_risk" (assigned only when drug_dosing wording did NOT match — pure dose/route/frequency questions structurally cannot fire) and documentTitleTerms > 0 (a curated title alias phrase is present for the alias tier to rescue with). Rescue semantics by construction: the S3 block sits after both fast-path returns, so a firing query has already had its pool floor-rejected. Blast radius proven twice over: exactly one eval case fires — my executed sweep and the retrieval reviewer's independent 110-case classifier probe agree. Honest live-expansion disclosure: real shapes like "When should clozapine be stopped?" now engage S3 (surfacing the title-named curated SOP for the named entity — assessed clinically correct; the principal thing the dedicated canary pair watches). No imputation formula, released-comparator key, selection clamp, or threshold is touched.

1aebf02 + a3b9a54 — monitoring evidence gate parity (answer-side). Run-#60's four monitoring targeting misses traced to the answer-intent evidence gate being narrower than the fact filter and the eval judge: inflected schedules ("reviewed annually", "monitored for 3 hours"), bare digit durations, and level-range/metabolic-panel vocabulary passed fact filtering but died at the gate, at kind classification, or at the intent-token coverage checks. One shared monitoringScheduleEvidencePattern now feeds both the gate and the filter (lockstep by construction), and both coverage checks gain a figure escape mirroring the concrete-dose escape, scoped to text carrying the asked-for interval or unit range itself. The review-response commit a3b9a54 closes both reviewer-found hazards: the inflected kind tokens no longer steal sole-dose-value sentences from the dose arm (legacy tokens classify byte-identically; new-inflection-only sentences fall through to dose when they carry a concrete dose value — both reviewer repro sentences pinned as tests), and the multi-drug bare-row guard extends to monitoring_schedule so a schedule row naming no drug inside a multi-drug chunk cannot inherit the queried drug (both governance-traced misattribution paths now refused, red-proven). Expected live effect: quality-lithium-monitoring-range + quality-antipsychotic-metabolic-monitoring gain their figures (monitoring targeting ≥3/5); the other two misses are retrieval-depth (documented residual).

All four reviewer subagent verdicts (pre-ready, full ledger rows on branch):

  • rag-retrieval-reviewer on parity: REQUEST-CHANGES (soft) — reproduced the dose-steal P2 (fails closed) + multi-drug P3 → both fixed in a3b9a54, red-proven both directions.
  • clinical-governance-reviewer on parity: APPROVE-WITH-NITS — its independently-converged P2 (multi-drug cross-entity attribution) is the same hazard, fixed in a3b9a54 exactly as its smallest-fix prescribed; unsupported-figures/conservative-failure/adjacent-context/PHI all verified safe.
  • rag-retrieval-reviewer on rescue: APPROVE-WITH-NITS, no P0/P1/P2 — independent 110-case probe confirms exactly one firing case; binding constraints byte-identical; downstream inert (empty requiredTermSignals; wrong-med cap never engages); S3 fixture shapes verified faithful to production values; redundant-optional-chain nit taken (55a6bc3).
  • clinical-governance-reviewer on rescue: APPROVE-WITH-NITS, no P0/P1 — wrong-document impossible (alias phrases must appear in the query; per-document groups), purely additive availability, adversarial fail-closed double layer executed, governance metadata unbypassed; P2 = the live canary trust gate below.

RAG impact: behaviour change — canary pair: run #60 (banked baseline on main 9b655fa) -> dedicated post-merge dispatch (answer_case_limit=44 + answer_quality_eval=true, ~$2-4, authorized envelope); success = citation_failure_rate 0.0227 -> 0, golden doc/content recall pinned 1.0/1.0, zero per-case rr@10 regressions, monitoring targeting ≥3/5, no other medication_dose_risk case's top-5 shifting; regression = single-commit revert of the offending commit per the proven drill.

Verification

  • Red-proofs both directions: parity — four tests verified failing pre-change; review-response — dose-steal repros + multi-drug guard verified red with fixes reverted; rescue — predicate + end-to-end ordering tests verified failing with the gate reverted; negative guards pin pure-dose/no-title/non-escalation shapes and the four allowlisted classes
  • Focused: escalation-rescue 8/8; imputation contract + fast-path-ordering + retrieval-selection + second-stage + ranking-tuning + eval-retrieval 143/143; extractive suites 147/147; reviewer-run batches 644/644 + 31/31
  • npm run verify:cheap — all static checks green; unit suite 3087 passed / known container-only pdf artifact
  • typecheck, prettier, maintainability budgets (rag.ts 4919/5030)
  • check:production-readiness — fails only on absent secrets in this demo container (expected per repo docs); hosted CI runs the CI-safe variant
  • Dedicated live canary pair post-merge (criteria in the RAG impact line)

Risk and rollout

  • Risk: medium — deliberate retrieval behaviour change on a protected surface, bounded by predicate narrowness (two ANDed deterministic classifier signals; two independent sweeps show one firing eval case), rescue-only semantics (S3 candidates ADD to the pool; previously-returned results remain retrievable — test-pinned), and the unchanged floor/selection/release contracts. The answer-side widen is bounded by the unchanged promotion guard + claim-support + numeric gates plus the new dose-steal and multi-drug guards (worst case stays a conservative evidence gap, never a wrong or misattributed figure).
  • Rollback: single revert per commit; no schema/env/RPC/cache changes.
  • Provider or production effects: the post-merge canary pair dispatch (~$2–4, user-authorized envelope).

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use — both changes sit upstream of the unchanged claim-support/numeric/citation gates
  • No patient-identifiable document workflow was introduced or expanded
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy) — no access changes
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative — S3-surfaced documents flow through the same governance annotation as all results
  • Deployment classification/TGA SaMD impact was checked: escalation queries gain the title-named curated SOP as top source; monitoring answers gain verbatim-supported, correctly-attributed schedules — both directions are toward the clinically correct document/figure, live-pair-validated before trust

🤖 Generated with Claude Code

https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9

Summary by CodeRabbit

  • New Features
    • Improved monitoring_schedule evidence understanding with inflection-tolerant phrasing (cadence/follow-up/baseline) and direct interval/range figure coverage.
    • Added a conditional “escalation rescue” for medication_dose_risk when escalation intent and matching document title terms are present.
  • Bug Fixes
    • Prevented monitoring evidence from being derived from dose-bearing sentences; expanded safe “bare row” handling for monitoring_schedule.
    • Strengthened monitoring-gate parity to admit valid interval/range facts without breaking stable, order-consistent retrieval.
  • Tests
    • Added monitoring evidence gate parity and escalation rescue/order-stability regression coverage; refined figure-coverage expectations.
  • Documentation
    • Updated the branch review ledger with new review outcomes and gates.

claude added 3 commits July 21, 2026 04:41
…iss class)

The monitoring-schedule answer gate was narrower than the fact filter and the
eval judge: inflected schedules (reviewed annually, monitored for 3 hours),
bare digit durations, and the level-range/metabolic-panel vocabulary passed
fact filtering but died at the gate or at kind classification, so answers for
those cases shipped without the asked-for schedule (run-#60 targeting misses).
One shared monitoringScheduleEvidencePattern now feeds both the gate and the
filter (lockstep by construction); the kind arm gains inflection tolerance
only (panel/range vocab would steal sentences from the dose arm — pinned by
the restored adjacent-context refusal test); and both the result-level and
sentence-level coverage checks gain a figure escape mirroring the existing
concrete-dose escape, tightly scoped to sentences/chunks that carry the
asked-for interval or unit range themselves. Four red-proof tests (each
verified failing pre-change) plus a negative guard pin the widen.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
…up layer

The neuroleptic-side-effect-escalation eval case failed the citation gate on
every canary (#57-#60): the query misclassifies as medication_dose_risk, its
honest lexical pool fails the dose fast-path floor (measured 0.184/0.0125 vs
0.66/0.055), the S3 document-lookup title layer that would surface the
title-named SOP was excluded by the class allowlist, and the vector leg then
injects the wrong sibling doc. shouldAttemptDocumentLookupFastPath now also
engages the layer for medication_dose_risk when the classifier's existing
deterministic signals say the query is escalation-shaped (intent
escalation_risk — only assigned when drug_dosing wording did NOT match, so
pure dose/route/frequency questions structurally cannot fire) AND a curated
title alias phrase is present for the alias tier to rescue with
(documentTitleTerms > 0). Rescue semantics by construction: the S3 block sits
after both fast-path returns, so a medication_dose_risk query only reaches it
once the floor already rejected the pool. Executed blast-radius sweep:
exactly one eval case fires across the 44-case answer canary, the 36-case
golden retrieval fixture, and the 30-case answer-quality harness — every
non-firing case executes byte-identical code. No imputation formula,
released-comparator key, selection clamp, or threshold is touched.

Red-proof: the predicate test and the end-to-end rescue ordering test both
fail with the gate reverted (verified); negative guards pin pure-dose,
no-title, and non-escalation shapes plus the four allowlisted classes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
@supabase

supabase Bot commented Jul 21, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5f094ce0-ecc2-40eb-9db4-a37632d02b7e

📥 Commits

Reviewing files that changed from the base of the PR and between e2a3996 and e3d1daa.

📒 Files selected for processing (1)
  • docs/branch-review-ledger.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/branch-review-ledger.md

📝 Walkthrough

Walkthrough

The PR broadens monitoring-schedule evidence recognition across extractive-answer gates and adds an intent- and title-gated document lookup rescue for escalation-shaped medication-dose-risk queries, with regression tests and review ledger records.

Changes

RAG evidence and retrieval

Layer / File(s) Summary
Monitoring evidence parity
src/lib/rag/rag-extractive-answer.ts, tests/extractive-answer-formatting.test.ts, docs/branch-review-ledger.md
Monitoring evidence recognizes inflected vocabulary, cadence and level ranges, duration figures, and schedule figures while preventing dose misclassification and multi-medication bare-row inheritance. Regression tests and parity decisions cover accepted and rejected cases.
Escalation document lookup rescue
src/lib/rag/rag.ts, tests/rag-document-lookup-escalation-rescue.test.ts, docs/branch-review-ledger.md
The exported fast-path helper accepts optional query analysis and enables lookup for escalation-shaped medication-dose-risk queries with curated title terms. Tests verify gating, rescued ordering, citation presence, fast-path acceptance, and insertion-order stability; review approvals are recorded in the ledger.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Query
  participant QueryAnalysis
  participant RAGPipeline
  participant DocumentLookup
  participant ReleasedOrdering
  Query->>RAGPipeline: submit escalation-shaped medication-dose-risk query
  RAGPipeline->>QueryAnalysis: obtain intent and title terms
  QueryAnalysis->>RAGPipeline: return escalation intent and curated title terms
  RAGPipeline->>DocumentLookup: enable lookup for qualifying queries
  DocumentLookup->>RAGPipeline: return S3 document candidates
  RAGPipeline->>ReleasedOrdering: rank and stabilize candidates
  ReleasedOrdering-->>Query: release rescued document ordering
Loading

Possibly related PRs

  • BigSimmo/Database#641: Refactors document-lookup fast-path searchers used by the retrieval pathway modified here.
  • BigSimmo/Database#1039: Modifies the same extractive-answer figure-aware selection and gating logic.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: escalation rescue and monitoring evidence gate parity.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/clinical-kb-pwa-review-asi3wb

Comment @coderabbitai help to get the list of available commands.

claude added 3 commits July 21, 2026 05:24
… (review P2/P3)

rag-retrieval-reviewer reproduced a dose-intent regression from the parity
commit: the inflected monitoring kind tokens (monitor\w*, annually, LFTs)
claimed sentences carrying a concrete dose value ('Quetiapine is monitored at
a dose of 200 mg daily'), and dose-intent answers then rejected the
monitoring-kind fact — a source-gap where the figure previously shipped. The
kind arm now classifies the legacy tokens byte-identically and lets a sentence
claimed ONLY via the new inflections fall through to the dose arm when it
carries a clinicalDoseValuePattern value; both reviewer repro sentences are
pinned as dose-intent tests. Also extends the multi-drug bare-row guard to
monitoring_schedule (reviewer P3 symmetry): the figure coverage escape made
bare interval rows admissible without a query token, so a row naming no drug
inside a multi-drug chunk must not inherit the queried drug — red-proof
verified both directions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
…hain nit

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
@BigSimmo
BigSimmo marked this pull request as ready for review July 21, 2026 05:34
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/rag/rag-extractive-answer.ts (1)

818-823: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Tighten the monitoring_schedule gate for dose facts

kind === "dose" is still allowed through this branch, and the current regex matches generic dose language like therapeutic, range, and maintenance. That lets sentences such as “The therapeutic dose range is 300-450 mg daily.” be extracted as monitoring-schedule evidence even though they contain no actual monitoring cadence/level signal. Require a real monitoring token for dose-kind facts before accepting them.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/rag/rag-extractive-answer.ts` around lines 818 - 823, Update the
monitoring_schedule branch in the evidence-kind gate so dose facts are accepted
only when the text contains an actual monitoring cadence or level token, rather
than generic dose terms matched by monitoringScheduleEvidencePattern. Preserve
the existing monitoring and renal_limit behavior, and reject dose text lacking
that monitoring-specific signal.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/branch-review-ledger.md`:
- Line 676: Fix the MD037 spacing violation in the ledger row’s Markdown
emphasis markers, ensuring no spaces appear immediately inside emphasized text
delimiters. Preserve the row’s content and formatting otherwise, then run the
Markdown lint fixer or equivalent validation.

---

Outside diff comments:
In `@src/lib/rag/rag-extractive-answer.ts`:
- Around line 818-823: Update the monitoring_schedule branch in the
evidence-kind gate so dose facts are accepted only when the text contains an
actual monitoring cadence or level token, rather than generic dose terms matched
by monitoringScheduleEvidencePattern. Preserve the existing monitoring and
renal_limit behavior, and reject dose text lacking that monitoring-specific
signal.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 50a0f8d6-fd57-468d-ac4f-e81727d63b30

📥 Commits

Reviewing files that changed from the base of the PR and between 4ac43aa and a8ed7a4.

📒 Files selected for processing (5)
  • docs/branch-review-ledger.md
  • src/lib/rag/rag-extractive-answer.ts
  • src/lib/rag/rag.ts
  • tests/extractive-answer-formatting.test.ts
  • tests/rag-document-lookup-escalation-rescue.test.ts

Comment thread docs/branch-review-ledger.md Outdated
…ignal

CodeRabbit major on the parity widen: kind===dose facts passed the shared
monitoring vocabulary via generic dose wording (range/therapeutic/maintenance
around a mg figure), so 'The therapeutic dose range is 300-450 mg daily.'
counted as monitoring-schedule evidence with no cadence/level signal. Dose-kind
facts now additionally require a cadence or level token
(monitoringCadenceOrLevelPattern — the strict schedule/level subset of the
shared vocabulary); level ranges like 'Maintenance range is 0.6-0.8 mmol/L'
stay admissible through their level units (red-proof pinned both directions).
Also escapes the literal vector-* asterisks in the ledger row flagged MD037.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9

Copy link
Copy Markdown
Owner Author

CodeRabbit's outside-diff major (dose-kind facts passing the monitoring gate via generic dose vocabulary) is fixed in 57a898f: factSupportsAnswerIntent's monitoring case now additionally requires a cadence or level token for kind === "dose" facts (monitoringCadenceOrLevelPattern — the strict schedule/level subset of the shared vocabulary). "The therapeutic dose range is 300-450 mg daily." is refused as monitoring evidence (discriminating test, red-proven both directions) while level ranges like "Maintenance range is 0.6-0.8 mmol/L" stay admissible through their level units. monitoring/renal_limit kinds are untouched per the finding's scope. Full suite 3088 passed (known container-only pdf artifact).


Generated by Claude Code

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/rag/rag-extractive-answer.ts (1)

485-499: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Prevent dose ranges from satisfying monitoring figure coverage.

monitoringFigureCoverage reuses a unit-range pattern that accepts mg, micrograms, and mcg. Therefore, text such as “The therapeutic dose range is 300-450 mg daily” can satisfy the monitoring intent gate even though the dose-kind guard at Line 837 rejects it. Restrict monitoring figure coverage to concentration/level units or explicitly exclude concrete dose evidence, and add a regression test.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/rag/rag-extractive-answer.ts` around lines 485 - 499, Update
monitoringFigureCoverage in the intent coverage logic to exclude concrete dose
ranges accepted by monitoringUnitRangeFigurePattern, restricting matches to
concentration/level units or applying the existing dose-kind guard before
coverage is granted. Preserve valid monitoring schedule and interval evidence,
and add a regression test confirming a therapeutic dose range such as “300-450
mg daily” cannot satisfy monitoring intent coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/lib/rag/rag-extractive-answer.ts`:
- Around line 485-499: Update monitoringFigureCoverage in the intent coverage
logic to exclude concrete dose ranges accepted by
monitoringUnitRangeFigurePattern, restricting matches to concentration/level
units or applying the existing dose-kind guard before coverage is granted.
Preserve valid monitoring schedule and interval evidence, and add a regression
test confirming a therapeutic dose range such as “300-450 mg daily” cannot
satisfy monitoring intent coverage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a014e33e-ef24-4a07-87dd-62e717d26003

📥 Commits

Reviewing files that changed from the base of the PR and between a8ed7a4 and 57a898f.

📒 Files selected for processing (3)
  • docs/branch-review-ledger.md
  • src/lib/rag/rag-extractive-answer.ts
  • tests/extractive-answer-formatting.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/extractive-answer-formatting.test.ts
  • docs/branch-review-ledger.md

…abbit major 2)

The result-level and sentence-level monitoring coverage escapes reused
monitoringUnitRangeFigurePattern, whose unit list includes dose-amount units
(mg/micrograms/mcg) — so a therapeutic dose range could still grant monitoring
intent coverage even though the dose-kind fact guard rejects the sentence
itself. Both escapes now use monitoringLevelRangeCoveragePattern
(mmol/L | nmol/L | mcg/L | ng/mL only); the wider pattern stays reserved for
the corpus-guarded figure-promotion checks. Regression test pins a token-free
chunk whose only candidate coverage grantor is a mg dose range.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9

Copy link
Copy Markdown
Owner Author

The second outside-diff major (dose-amount ranges satisfying the monitoring coverage escapes) is fixed in d6c218a: both the result-level and sentence-level escapes now use monitoringLevelRangeCoveragePattern (mmol/L | nmol/L | mcg/L | ng/mL only), while the wider monitoringUnitRangeFigurePattern stays reserved for the corpus-guarded figure-promotion checks. Regression test added per the finding: a token-free chunk whose only candidate coverage grantor is "300-450 mg daily" ships nothing. Note the exposure was already closed end-to-end by the dose-kind guard from 57a898f (the sentence could gain coverage but never became a fact); this narrows the coverage layer itself for defense-in-depth consistency. Full suite 3089 passed (known container-only pdf artifact).


Generated by Claude Code

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/extractive-answer-formatting.test.ts`:
- Around line 575-584: Update the fixture in the test named “denies monitoring
intent coverage to a dose-amount range in a token-free chunk” so its content
contains only the dose range and neutral surrounding text, with no
monitoring-related or broader vocabulary such as “therapeutic,” “range,” or
“daily.” Preserve the assertion’s purpose of proving that “300-450 mg” alone
cannot grant monitoring coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fdf35d51-b2d0-40b5-baa1-c5d6b8d416e1

📥 Commits

Reviewing files that changed from the base of the PR and between 57a898f and d6c218a.

📒 Files selected for processing (2)
  • src/lib/rag/rag-extractive-answer.ts
  • tests/extractive-answer-formatting.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/rag/rag-extractive-answer.ts

Comment thread tests/extractive-answer-formatting.test.ts
@BigSimmo
BigSimmo merged commit cde6c5c into main Jul 21, 2026
18 checks passed
@BigSimmo
BigSimmo deleted the claude/clinical-kb-pwa-review-asi3wb branch July 21, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants